home *** CD-ROM | disk | FTP | other *** search
/ This Disc Bytes! / Power Computing - The Disc 2 - This Disc Bytes.ISO / mac / CodeWarrior 7 Lite for 68K / MacOS Support / Headers / Universal Headers / DatabaseAccess.h < prev    next >
Text File  |  1995-07-06  |  13KB  |  326 lines

  1. /*
  2.      File:        DatabaseAccess.h
  3.  
  4.      Contains:    Database Access Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __DATABASEACCESS__
  21. #define __DATABASEACCESS__
  22.  
  23.  
  24. #ifndef __RESOURCES__
  25. #include <Resources.h>
  26. #endif
  27. /*    #include <Types.h>                                            */
  28. /*        #include <ConditionalMacros.h>                            */
  29. /*    #include <MixedMode.h>                                        */
  30. /*    #include <Files.h>                                            */
  31. /*        #include <OSUtils.h>                                    */
  32. /*            #include <Memory.h>                                    */
  33. /*        #include <Finder.h>                                        */
  34.  
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38.  
  39. #if PRAGMA_ALIGN_SUPPORTED
  40. #pragma options align=mac68k
  41. #endif
  42.  
  43. #if PRAGMA_IMPORT_SUPPORTED
  44. #pragma import on
  45. #endif
  46.  
  47.  
  48. enum {
  49.     typeNone                    = 'none',
  50.     typeDate                    = 'date',
  51.     typeTime                    = 'time',
  52.     typeTimeStamp                = 'tims',
  53.     typeDecimal                    = 'deci',
  54.     typeMoney                    = 'mone',
  55.     typeVChar                    = 'vcha',
  56.     typeVBin                    = 'vbin',
  57.     typeLChar                    = 'lcha',
  58.     typeLBin                    = 'lbin',
  59.     typeDiscard                    = 'disc',
  60. /* "dummy" types for DBResultsToText */
  61.     typeUnknown                    = 'unkn',
  62.     typeColBreak                = 'colb',
  63.     typeRowBreak                = 'rowb',
  64. /* pass this in to DBGetItem for any data type */
  65.     typeAnyType                    = 0
  66. };
  67.  
  68. /* infinite timeout value for DBGetItem */
  69. enum {
  70. /* messages for status functions for DBStartQuery */
  71.     kDBUpdateWind                = 0,
  72.     kDBAboutToInit                = 1,
  73.     kDBInitComplete                = 2,
  74.     kDBSendComplete                = 3,
  75.     kDBExecComplete                = 4,
  76.     kDBStartQueryComplete        = 5
  77. };
  78.  
  79. enum {
  80. /* messages for status functions for DBGetQueryResults */
  81.     kDBGetItemComplete            = 6,
  82.     kDBGetQueryResultsComplete    = 7,
  83.     kDBWaitForever                = -1,
  84. /*  flags for DBGetItem  */
  85.     kDBLastColFlag                = 0x0001,
  86.     kDBNullFlag                    = 0x0004
  87. };
  88.  
  89. typedef OSType DBType;
  90.  
  91. typedef struct DBAsyncParamBlockRec DBAsyncParamBlockRec, *DBAsyncParmBlkPtr;
  92.  
  93. /*
  94.         DBCompletionProcPtr uses register based parameters on the 68k and cannot
  95.         be written in or called from a high-level language without the help of
  96.         mixed mode or assembly glue.
  97.  
  98.             typedef pascal void (*DBCompletionProcPtr)(DBAsyncParmBlkPtr pb);
  99.  
  100.         In:
  101.          => pb              A1.L
  102. */
  103.  
  104. #if GENERATINGCFM
  105. typedef UniversalProcPtr DBCompletionUPP;
  106. #else
  107. typedef Register68kProcPtr DBCompletionUPP;
  108. #endif
  109.  
  110. struct DBAsyncParamBlockRec {
  111.     DBCompletionUPP                    completionProc;                /* pointer to completion routine */
  112.     OSErr                            result;                        /* result of call */
  113.     long                            userRef;                    /* for application's use */
  114.     long                            ddevRef;                    /* for ddev's use */
  115.     long                            reserved;                    /* for internal use */
  116. };
  117. enum {
  118.     uppDBCompletionProcInfo = kRegisterBased
  119.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA1, SIZE_CODE(sizeof(DBAsyncParmBlkPtr)))
  120. };
  121.  
  122. #if GENERATINGCFM
  123. #define CallDBCompletionProc(userRoutine, pb)        \
  124.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppDBCompletionProcInfo, (pb))
  125. #else
  126. /* (*DBCompletionProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  127. #endif
  128.  
  129. #if GENERATINGCFM
  130. #define NewDBCompletionProc(userRoutine)        \
  131.         (DBCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppDBCompletionProcInfo, GetCurrentArchitecture())
  132. #else
  133. #define NewDBCompletionProc(userRoutine)        \
  134.         ((DBCompletionUPP) (userRoutine))
  135. #endif
  136.  
  137. struct ResListElem {
  138.     ResType                            theType;                    /* resource type */
  139.     short                            id;                            /* resource id */
  140. };
  141. typedef struct ResListElem ResListElem;
  142.  
  143. typedef ResListElem *ResListPtr, **ResListHandle;
  144.  
  145. /* structure for query list in QueryRecord */
  146. typedef Handle QueryArray[256];
  147.  
  148. typedef Handle **QueryListHandle;
  149.  
  150. struct QueryRecord {
  151.     short                            version;                    /* version */
  152.     short                            id;                            /* id of 'qrsc' this came from */
  153.     Handle                            queryProc;                    /* handle to query def proc */
  154.     Str63                            ddevName;                    /* ddev name */
  155.     Str255                            host;                        /* host name */
  156.     Str255                            user;                        /* user name */
  157.     Str255                            password;                    /* password */
  158.     Str255                            connStr;                    /* connection string */
  159.     short                            currQuery;                    /* index of current query */
  160.     short                            numQueries;                    /* number of queries in list */
  161.     QueryListHandle                    queryList;                    /* handle to array of handles to text */
  162.     short                            numRes;                        /* number of resources in list */
  163.     ResListHandle                    resList;                    /* handle to array of resource list elements */
  164.     Handle                            dataHandle;                    /* for use by query def proc */
  165.     long                            refCon;                        /* for use by application */
  166. };
  167. typedef struct QueryRecord QueryRecord;
  168.  
  169. typedef QueryRecord *QueryPtr, **QueryHandle;
  170.  
  171. /* structure of column types array in ResultsRecord */
  172. typedef DBType ColTypesArray[256];
  173.  
  174. typedef Handle ColTypesHandle;
  175.  
  176. struct DBColInfoRecord {
  177.     short                            len;
  178.     short                            places;
  179.     short                            flags;
  180. };
  181. typedef struct DBColInfoRecord DBColInfoRecord;
  182.  
  183. typedef DBColInfoRecord ColInfoArray[256];
  184.  
  185. typedef Handle ColInfoHandle;
  186.  
  187. struct ResultsRecord {
  188.     short                            numRows;                    /* number of rows in result */
  189.     short                            numCols;                    /* number of columns per row */
  190.     ColTypesHandle                    colTypes;                    /* data type array */
  191.     Handle                            colData;                    /* actual results */
  192.     ColInfoHandle                    colInfo;                    /* DBColInfoRecord array */
  193. };
  194. typedef struct ResultsRecord ResultsRecord;
  195.  
  196. typedef pascal OSErr (*DBQueryDefProcPtr)(long *sessID, QueryHandle query);
  197. typedef pascal Boolean (*DBStatusProcPtr)(short message, OSErr result, short dataLen, short dataPlaces, short dataFlags, DBType dataType, Ptr dataPtr);
  198. typedef pascal OSErr (*DBResultHandlerProcPtr)(DBType dataType, short theLen, short thePlaces, short theFlags, Ptr theData, Handle theText);
  199.  
  200. #if GENERATINGCFM
  201. typedef UniversalProcPtr DBQueryDefUPP;
  202. typedef UniversalProcPtr DBStatusUPP;
  203. typedef UniversalProcPtr DBResultHandlerUPP;
  204. #else
  205. typedef DBQueryDefProcPtr DBQueryDefUPP;
  206. typedef DBStatusProcPtr DBStatusUPP;
  207. typedef DBResultHandlerProcPtr DBResultHandlerUPP;
  208. #endif
  209.  
  210. enum {
  211.     uppDBQueryDefProcInfo = kPascalStackBased
  212.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  213.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long*)))
  214.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(QueryHandle))),
  215.     uppDBStatusProcInfo = kPascalStackBased
  216.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  217.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  218.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(OSErr)))
  219.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  220.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short)))
  221.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(short)))
  222.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(DBType)))
  223.          | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(Ptr))),
  224.     uppDBResultHandlerProcInfo = kPascalStackBased
  225.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  226.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DBType)))
  227.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  228.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  229.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short)))
  230.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(Ptr)))
  231.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(Handle)))
  232. };
  233.  
  234. #if GENERATINGCFM
  235. #define NewDBQueryDefProc(userRoutine)        \
  236.         (DBQueryDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppDBQueryDefProcInfo, GetCurrentArchitecture())
  237. #define NewDBStatusProc(userRoutine)        \
  238.         (DBStatusUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppDBStatusProcInfo, GetCurrentArchitecture())
  239. #define NewDBResultHandlerProc(userRoutine)        \
  240.         (DBResultHandlerUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppDBResultHandlerProcInfo, GetCurrentArchitecture())
  241. #else
  242. #define NewDBQueryDefProc(userRoutine)        \
  243.         ((DBQueryDefUPP) (userRoutine))
  244. #define NewDBStatusProc(userRoutine)        \
  245.         ((DBStatusUPP) (userRoutine))
  246. #define NewDBResultHandlerProc(userRoutine)        \
  247.         ((DBResultHandlerUPP) (userRoutine))
  248. #endif
  249.  
  250. #if GENERATINGCFM
  251. #define CallDBQueryDefProc(userRoutine, sessID, query)        \
  252.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppDBQueryDefProcInfo, (sessID), (query))
  253. #define CallDBStatusProc(userRoutine, message, result, dataLen, dataPlaces, dataFlags, dataType, dataPtr)        \
  254.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppDBStatusProcInfo, (message), (result), (dataLen), (dataPlaces), (dataFlags), (dataType), (dataPtr))
  255. #define CallDBResultHandlerProc(userRoutine, dataType, theLen, thePlaces, theFlags, theData, theText)        \
  256.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppDBResultHandlerProcInfo, (dataType), (theLen), (thePlaces), (theFlags), (theData), (theText))
  257. #else
  258. #define CallDBQueryDefProc(userRoutine, sessID, query)        \
  259.         (*(userRoutine))((sessID), (query))
  260. #define CallDBStatusProc(userRoutine, message, result, dataLen, dataPlaces, dataFlags, dataType, dataPtr)        \
  261.         (*(userRoutine))((message), (result), (dataLen), (dataPlaces), (dataFlags), (dataType), (dataPtr))
  262. #define CallDBResultHandlerProc(userRoutine, dataType, theLen, thePlaces, theFlags, theData, theText)        \
  263.         (*(userRoutine))((dataType), (theLen), (thePlaces), (theFlags), (theData), (theText))
  264. #endif
  265.  
  266. extern pascal OSErr InitDBPack(void)
  267.  FIVEWORDINLINE(0x3F3C, 0x0004, 0x303C, 0x0100, 0xA82F);
  268. extern pascal OSErr DBInit(long *sessID, ConstStr63Param ddevName, ConstStr255Param host, ConstStr255Param user, ConstStr255Param passwd, ConstStr255Param connStr, DBAsyncParmBlkPtr asyncPB)
  269.  THREEWORDINLINE(0x303C, 0x0E02, 0xA82F);
  270. extern pascal OSErr DBEnd(long sessID, DBAsyncParmBlkPtr asyncPB)
  271.  THREEWORDINLINE(0x303C, 0x0403, 0xA82F);
  272. extern pascal OSErr DBGetConnInfo(long sessID, short sessNum, long *returnedID, long *version, Str63 ddevName, Str255 host, Str255 user, Str255 network, Str255 connStr, long *start, OSErr *state, DBAsyncParmBlkPtr asyncPB)
  273.  THREEWORDINLINE(0x303C, 0x1704, 0xA82F);
  274. extern pascal OSErr DBGetSessionNum(long sessID, short *sessNum, DBAsyncParmBlkPtr asyncPB)
  275.  THREEWORDINLINE(0x303C, 0x0605, 0xA82F);
  276. extern pascal OSErr DBSend(long sessID, Ptr text, short len, DBAsyncParmBlkPtr asyncPB)
  277.  THREEWORDINLINE(0x303C, 0x0706, 0xA82F);
  278. extern pascal OSErr DBSendItem(long sessID, DBType dataType, short len, short places, short flags, void *buffer, DBAsyncParmBlkPtr asyncPB)
  279.  THREEWORDINLINE(0x303C, 0x0B07, 0xA82F);
  280. extern pascal OSErr DBExec(long sessID, DBAsyncParmBlkPtr asyncPB)
  281.  THREEWORDINLINE(0x303C, 0x0408, 0xA82F);
  282. extern pascal OSErr DBState(long sessID, DBAsyncParmBlkPtr asyncPB)
  283.  THREEWORDINLINE(0x303C, 0x0409, 0xA82F);
  284. extern pascal OSErr DBGetErr(long sessID, long *err1, long *err2, Str255 item1, Str255 item2, Str255 errorMsg, DBAsyncParmBlkPtr asyncPB)
  285.  THREEWORDINLINE(0x303C, 0x0E0A, 0xA82F);
  286. extern pascal OSErr DBBreak(long sessID, Boolean abort, DBAsyncParmBlkPtr asyncPB)
  287.  THREEWORDINLINE(0x303C, 0x050B, 0xA82F);
  288. extern pascal OSErr DBGetItem(long sessID, long timeout, DBType *dataType, short *len, short *places, short *flags, void *buffer, DBAsyncParmBlkPtr asyncPB)
  289.  THREEWORDINLINE(0x303C, 0x100C, 0xA82F);
  290. extern pascal OSErr DBUnGetItem(long sessID, DBAsyncParmBlkPtr asyncPB)
  291.  THREEWORDINLINE(0x303C, 0x040D, 0xA82F);
  292. extern pascal OSErr DBKill(DBAsyncParmBlkPtr asyncPB)
  293.  THREEWORDINLINE(0x303C, 0x020E, 0xA82F);
  294. extern pascal OSErr DBGetNewQuery(short queryID, QueryHandle *query)
  295.  THREEWORDINLINE(0x303C, 0x030F, 0xA82F);
  296. extern pascal OSErr DBDisposeQuery(QueryHandle query)
  297.  THREEWORDINLINE(0x303C, 0x0210, 0xA82F);
  298. extern pascal OSErr DBStartQuery(long *sessID, QueryHandle query, DBStatusUPP statusProc, DBAsyncParmBlkPtr asyncPB)
  299.  THREEWORDINLINE(0x303C, 0x0811, 0xA82F);
  300. extern pascal OSErr DBGetQueryResults(long sessID, ResultsRecord *results, long timeout, DBStatusUPP statusProc, DBAsyncParmBlkPtr asyncPB)
  301.  THREEWORDINLINE(0x303C, 0x0A12, 0xA82F);
  302. extern pascal OSErr DBResultsToText(ResultsRecord *results, Handle *theText)
  303.  THREEWORDINLINE(0x303C, 0x0413, 0xA82F);
  304. extern pascal OSErr DBInstallResultHandler(DBType dataType, DBResultHandlerUPP theHandler, Boolean isSysHandler)
  305.  THREEWORDINLINE(0x303C, 0x0514, 0xA82F);
  306. extern pascal OSErr DBRemoveResultHandler(DBType dataType)
  307.  THREEWORDINLINE(0x303C, 0x0215, 0xA82F);
  308. extern pascal OSErr DBGetResultHandler(DBType dataType, DBResultHandlerUPP *theHandler, Boolean getSysHandler)
  309.  THREEWORDINLINE(0x303C, 0x0516, 0xA82F);
  310. extern pascal OSErr DBIdle(void)
  311.  THREEWORDINLINE(0x303C, 0x00FF, 0xA82F);
  312.  
  313. #if PRAGMA_IMPORT_SUPPORTED
  314. #pragma import off
  315. #endif
  316.  
  317. #if PRAGMA_ALIGN_SUPPORTED
  318. #pragma options align=reset
  319. #endif
  320.  
  321. #ifdef __cplusplus
  322. }
  323. #endif
  324.  
  325. #endif /* __DATABASEACCESS__ */
  326.